package learning.socket3;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.net.Socket;

public class User {
	public static void main(String[] args) {
		Socket s=null;
		File dsf=new File("E:/bcd.mp4");
		try {
			s=new Socket("localhost", 2222);
			BufferedInputStream bis=new BufferedInputStream(s.getInputStream());
			BufferedOutputStream bos=new BufferedOutputStream(new FileOutputStream(dsf));
			byte[] bb=new byte[1024*1024];
			int len=0;
			long sts=System.currentTimeMillis();
			while((len=bis.read(bb))!=-1){
				bos.write(bb, 0, len);
			}
			System.out.println("Download finished last for "+(System.currentTimeMillis()-sts)+"mm");
			bis.close();
			bos.close();
			s.close();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
